package com.zjc.mymq.client.consumer;


import com.alibaba.fastjson.JSON;
import com.zjc.mymq.client.netty.BrokerRemoteRespHandler;
import com.zjc.mymq.common.coder.TcpMsg;
import com.zjc.mymq.common.dto.CreateTopicReqDTO;
import com.zjc.mymq.common.enums.BrokerEventCode;
import com.zjc.mymq.common.event.EventBus;
import com.zjc.mymq.common.remote.BrokerNettyRemoteClient;

/**
 * @author zjc
 * @date Created at 2024/8/7
 *  创建topic的class
 */
public class CreateTopicCommand {


    public static void main(String[] args) {
        BrokerNettyRemoteClient brokerNettyRemoteClient = new BrokerNettyRemoteClient("127.0.0.1", 8990);
        brokerNettyRemoteClient.buildConnection(new BrokerRemoteRespHandler(new EventBus("mq-client-eventbus")));
        CreateTopicReqDTO createTopicReqDTO = new CreateTopicReqDTO();
        createTopicReqDTO.setTopic("dead_queue");
        createTopicReqDTO.setQueueSize(3);
        brokerNettyRemoteClient.sendAsyncMsg(new TcpMsg(BrokerEventCode.CREATE_TOPIC.getCode(), JSON.toJSONBytes(createTopicReqDTO)));
    }
}
